<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport"
	content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no" />
<meta name="full-screen" content="yes" />
<meta name="browsermode" content="application" />
<!-- QQ强制竖屏 QQ强制全屏 -->
<meta name="x5-orientation" content="portrait" />
<meta name="x5-fullscreen" content="true" />
<meta name="x5-page-mode" content="app" />
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<title>新年标签</title>
<link rel="stylesheet" href="css/newyear.css?v=1" type="text/css"/>
</head>
<body>
<img src="/image/share.jpg" style="width:100px;height:100px;position:absolute;top:20%;left:20%;"/>
<div class="nYTipBj" id="wxTip">
   <img src="/image/hint.png" class="wxTip" >
</div>

<div class="small01">姓名不能为空</div>
<section class="yearW">
      <div class="yearInt">
      <img src="/image/year1.png">
      <h1 name="nameIn">--</h1>
      <p>将得到</p>
      <h2 name="getDescribe">--</h2>
     <img src="/image/year2.png">
     </div>
     <div class="btnName"><input type="text" value="" placeholder="请输入姓名" id="nameVal"></div>
     <div class="btn" id="submitName">确定</div>
     <div class="btn" id="share">分享给朋友</div>
</section>
<script type="text/javascript">

document.querySelector("html").setAttribute("style", "font-size:" + document.body.clientWidth / 20 + "px");
$("#share").click(function(){
	$("#wxTip").show();
});

var json=["爱你的人","一套大房" ,"一大笔钱","一辆豪车","一个健康的身体","棒棒哒工作","瘦瘦瘦瘦","逢考必过神技能","工资翻倍","吃不完的美食","穿不完的新衣服","一次说走就走的旅行","与喜欢的人天天相见","与偶像的近距离接触","一年的开心","节假日永不加班的好运","永远18岁的脸","马甲线小腹肌","暗恋对象的表白","前任孤独终生"];

function rnd() {
    var random = parseInt(Math.random() * json.length);
    return random;
}

$("#submitName").click(function(){
	var nameVal=$("#nameVal").val();
	if(nameVal==''){
	   $(".small01").show();
           setTimeout(function(){
                 $(".small01").fadeOut()
			},1000);						 
		return;
	}else{
	     var index = getHashCode(nameVal,true)%json.length;
		 var msg = json[index];
		 var title="2017年"+nameVal+"会得到"+msg+"，快来看看你会得到什么？";
		 var url="http://"+location.host+"/newyear.html?name="
				 +encodeURI(encodeURI(nameVal))+"&msg="+encodeURI(encodeURI(msg));
		var state = {
			title: title,
			url: url
		};
		document.title = title;
		window.history.pushState(state, title, url);
		 $("h1[name=nameIn]").html(nameVal);
		 $("h2[name=getDescribe]").html(msg);
		 $("#nameVal,#submitName").hide();
		 $("#share,#linkA").css("display","block");
	}
	log("点击提交");
});
/**
 * 获取字符串的哈希值
 * @param {String} str
 * @param {Boolean} caseSensitive
 * @return {Number} hashCode
 */
function getHashCode(str,caseSensitive){
    if(!caseSensitive){
        str = str.toLowerCase();
    }
    var hash  =   1315423911,i,ch;
    for (i = str.length - 1; i >= 0; i--) {
        ch = str.charCodeAt(i);
        hash ^= ((hash << 5) + ch + (hash >> 2));
    }
    return  (hash & 0x7FFFFFFF);
}

function getQueryString(name) {
	var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
	var r = window.location.search.substr(1).match(reg);
	if (r != null) {
		return unescape(r[2]);
	}
	return "";
}

$(function(){
	var name_en = getQueryString("name");
	var msg_en = getQueryString("msg");
	if(name_en && msg_en){
		var name = decodeURIComponent(name_en);
		var msg = decodeURIComponent(msg_en);
		$("h1[name=nameIn]").html(name);
		$("h2[name=getDescribe]").html(msg);
	}
	
	$("#wxTip").click(function(){
		$(this).hide();
	});
});
</script>
<script>
	var _hmt = _hmt || [];
	(function() {
	var hm = document.createElement("script");
	hm.src = "https://hm.baidu.com/hm.js?4fb69ba1f00cba3a9bd1d7087378ae94";
	var s = document.getElementsByTagName("script")[0]; 
	s.parentNode.insertBefore(hm, s);
	})();

	function log(msg) {
		_hmt.push(["_trackEvent", msg, msg]);
	}
</script>
</body>
</html>